//
//  CellForHotNone.m
//  MY Project For Sport
//
//  Created by dllo on 16/2/26.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForHotNone.h"
#import "ModelForHot.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <DKNightVersion.h>
#import "UIColor+Wonderful.h"
#define WEIGHT self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667

@interface CellForHotNone ()

@property (nonatomic, retain) UILabel *team1;
@property (nonatomic, retain) UILabel *team2;
@property (nonatomic, retain) UILabel *score1;
@property (nonatomic, retain) UILabel *score2;
@property (nonatomic, retain) UILabel *leagueType;
@property (nonatomic, retain) UILabel *round;
@property (nonatomic, retain) UIImageView *team1View;
@property (nonatomic, retain) UIImageView *team2View;
@property (nonatomic, retain) UIView *myView;
@property (nonatomic, retain) UILabel *current;
@property (nonatomic, retain) UILabel *data;
@property (nonatomic, retain) UILabel *play;
@end

@implementation CellForHotNone

-(void)dealloc {

    [_team1 release];
    [_team2 release];
    [_score1 release];
    [_score2 release];
    [_leagueType release];
    [_round release];
    [_data release];
    [_team1View release];
    [_team2View release];
    [_myView release];
    [_current release];
    [_play release];
    [super dealloc];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor linenColor], [UIColor grayColor]);

        
        [self createSubview];
        
    }
    
    return self;
    
}

#pragma mark - 创建 cell 上面的子视图
- (void)createSubview {
    
    
    self.myView = [[UIView alloc] init];
    [self.contentView addSubview:self.myView];
    self.myView.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor dimGray]);
    [_myView release];
    
    self.leagueType = [[UILabel alloc] init];
    self.leagueType.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.leagueType];
    [_leagueType release];
    
    self.round = [[UILabel alloc] init];
    self.round.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.round];
    [_round release];
    
    self.team1 = [[UILabel alloc] init];
    [self.contentView addSubview:self.team1];
    [_team1 release];
    
    
    self.team2 = [[UILabel alloc] init];
    [self.contentView addSubview:self.team2];
    [_team2 release];
    
    self.score1 = [[UILabel alloc] init];
    self.score1.font = [UIFont systemFontOfSize:20];
    [self.contentView addSubview:self.score1];
    [_score1 release];
    
    
    self.score2 = [[UILabel alloc] init];
    self.score2.font = [UIFont systemFontOfSize:20];
    [self.contentView addSubview:self.score2];
    [_score2 release];
    
    self.team1View = [[UIImageView alloc] init];
    [self.contentView addSubview:self.team1View];
    [_team1View release];
    
    self.team2View = [[UIImageView alloc] init];
    [self.contentView addSubview:self.team2View];
    [_team2View release];
    
    self.current = [[UILabel alloc] init];
    [self.contentView addSubview:self.current];
    [_current release];
    
    self.data = [[UILabel alloc] init];
    [self.contentView addSubview:self.data];
    [_data release];
    
    self.play = [[UILabel alloc] init];
    [self.contentView addSubview:self.play];
    [_play release];
    
    
}

-(void)layoutSubviews {
    
    [super layoutSubviews];
 
    self.myView.frame = CGRectMake(3 * WEIGHTT, 5 * HEIGHTT, WEIGHT - 6 * WEIGHTT, HEIGHT - 10 * HEIGHTT);
    
    self.leagueType.frame = CGRectMake(10 * WEIGHTT, 10 * HEIGHTT, WEIGHT / 9.4, HEIGHT / 8.4);
    self.leagueType.dk_textColorPicker = DKColorWithColors([UIColor grayColor], [UIColor whiteColor]);
    
    self.data.frame = CGRectMake(WEIGHT / 3 * 2, 10 * HEIGHTT, WEIGHT / 4, HEIGHT / 8.4);

    self.round.frame = CGRectMake(WEIGHT / 9.4 + (10 + 5) * WEIGHTT, 10 * HEIGHTT, WEIGHT / 9.4, HEIGHT / 8.4);

    
    self.round.dk_textColorPicker = DKColorWithColors([UIColor grayColor], [UIColor whiteColor]);
    
    self.team1View.frame = CGRectMake(10 * WEIGHTT, 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT, WEIGHT / 8.3, WEIGHT / 8.3);
    self.team1View.layer.cornerRadius = WEIGHT / 16.6;
    self.team1View.layer.masksToBounds = YES;
    
    self.team2View.frame = CGRectMake(10 * WEIGHTT, 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + WEIGHT / 8.3 + 10 * HEIGHTT, WEIGHT / 8.3 ,WEIGHT / 8.3);
    self.team2View.layer.cornerRadius = WEIGHT / 16.6;
    self.team2View.layer.masksToBounds = YES;
    
    
    self.team1.frame = CGRectMake(10 * WEIGHTT +  WEIGHT / 8.3 + 10 * WEIGHTT, 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT, WEIGHT / 3.1, WEIGHT / 8.3);
    self.team1.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);

    
    self.team2.frame = CGRectMake(10 * WEIGHTT +  WEIGHT / 8.3 + 10 * WEIGHTT, 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + WEIGHT / 8.3 + 10 * HEIGHTT, WEIGHT / 3.1,WEIGHT / 8.3);
    self.team2.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    
    self.score1.frame = CGRectMake(WEIGHT / 1.8, 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT, WEIGHT / 10, WEIGHT / 8.3);
    self.score1.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);

    
    self.score2.frame = CGRectMake(WEIGHT / 1.8, 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + WEIGHT / 8.3 + 10 * HEIGHTT, WEIGHT / 10, WEIGHT / 8.3);
    self.score2.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    self.play.frame = CGRectMake(WEIGHT / 1.8 + WEIGHT / 10 + 3 * WEIGHTT, (10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + 10 * HEIGHTT + 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + WEIGHT / 8.3 + 10 * HEIGHTT) / 2, WEIGHT / 6, WEIGHT / 12);

    
    self.current.frame = CGRectMake(WEIGHT / 1.5 + WEIGHT / 10 + 20 * WEIGHTT,(10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + 10 * HEIGHTT + HEIGHT / 8.4 + 10 * HEIGHTT + WEIGHT / 8.3 + 10 * HEIGHTT) / 2, WEIGHT / 8, WEIGHT / 8);
    self.current.layer.cornerRadius = WEIGHT / 16;
    self.current.layer.masksToBounds = YES;
    self.current.backgroundColor = Wonderful_GrayColor2;
    self.current.textAlignment = NSTextAlignmentCenter;

    
    
    
}

-(void)passModelForHot:(ModelForHot *)hotModel {
    
    self.leagueType.text = hotModel.LeagueType_cn;
    self.round.text = hotModel.Round_cn;
    //    self.date.text = hotModel.date;
    self.team1.text = hotModel.Team1;
    self.team2.text = hotModel.Team2;
    self.score1.text = hotModel.Score1;
    self.score2.text = hotModel.Score2;
    self.data.text = hotModel.date;
    self.data.font = [UIFont systemFontOfSize:15];
    [self.team1View sd_setImageWithURL:[NSURL URLWithString:hotModel.Flag1]];
    [self.team2View sd_setImageWithURL:[NSURL URLWithString:hotModel.Flag2]];
    
    if ([hotModel.status isEqualToString:@"2"]) {
        
        self.current.text = @"进行中";
        self.current.textColor = [UIColor redColor];
          self.current.font = [UIFont systemFontOfSize:15];
        
        self.play.font = [UIFont systemFontOfSize:13];
        self.play.text = @"互动直播";
        self.play.textColor = [UIColor blueColor];
        
    } else if ([hotModel.status isEqualToString:@"1"]) {
    
        
        self.current.text = @"未";
        self.current.textColor = [UIColor redColor];
        
        self.play.text = hotModel.time;
        self.play.textColor = [UIColor redColor];
        self.play.font = [UIFont systemFontOfSize:13];

    }
    
    else {
        
        self.current.text = @"结束";
        self.current.textColor = [UIColor blackColor];
        self.play.text = @"";
    }
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
